<template>
  <!-- 发展史 -->
  <div class="historyOfDevelopment">
    <div class="addBtn">
      <button>新增</button>
    </div>
    <div class="itemBox">
      <div class="itemTitle">
        <div class="serial_number">序号</div>
        <div class="title">标题</div>
        <div class="img">图片</div>
        <div class="description">概述</div>
      </div>
      <div class="itemList">
        <div class="serial_number">1</div>
        <div class="title">
          <input type="text" />
        </div>
        <div class="img">
          <div class="uploads">
            <el-upload
              class="avatar-uploader"
              action="https://jsonplaceholder.typicode.com/posts/"
              :show-file-list="false"
              :on-success="handleAvatarSuccess"
              :before-upload="beforeAvatarUpload"
            >
              <img v-if="imageUrl1" :src="imageUrl" class="avatar" />
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload>
          </div>
        </div>
        <div class="description">
          <el-input
            type="textarea"
            placeholder="不超过100字"
            show-word-limit
            maxlength="100"
            :rows="5"
            v-model="textarea2"
          ></el-input>
        </div>
      </div>
      <div class="itemList">
        <div class="serial_number">2</div>
        <div class="title">
          <input type="text" />
        </div>
        <div class="img">
          <div class="uploads">
            <el-upload
              class="avatar-uploader"
              action="https://jsonplaceholder.typicode.com/posts/"
              :show-file-list="false"
              :on-success="handleAvatarSuccess"
              :before-upload="beforeAvatarUpload"
            >
              <img v-if="imageUrl2" :src="imageUrl" class="avatar" />
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload>
          </div>
        </div>
        <div class="description">
          <el-input
            type="textarea"
            placeholder="不超过100字"
            show-word-limit
            maxlength="100"
            :rows="5"
            v-model="textarea4"
          ></el-input>
        </div>
      </div>
      <div class="itemList">
        <div class="serial_number">3</div>
        <div class="title">
          <input type="text" />
        </div>
        <div class="img">
          <div class="uploads">
            <el-upload
              class="avatar-uploader"
              action="https://jsonplaceholder.typicode.com/posts/"
              :show-file-list="false"
              :on-success="handleAvatarSuccess"
              :before-upload="beforeAvatarUpload"
            >
              <img v-if="imageUrl3" :src="imageUrl" class="avatar" />
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload>
          </div>
        </div>
        <div class="description">
          <el-input
            type="textarea"
            placeholder="不超过100字"
            show-word-limit
            maxlength="100"
            :rows="5"
            v-model="textarea6"
          ></el-input>
        </div>
      </div>
    </div>
    <div class="btns">
      <button>保存</button>
      <button>提交</button>
      <button>预览</button>
    </div>
  </div>
</template>
<script>
export default {
  name: "",
  components: {},
  data() {
    return {
      textarea1: "",
      textarea2: "",
      textarea3: "",
      textarea4: "",
      textarea5: "",
      textarea6: "",
      imageUrl1: "",
      imageUrl2: "",
      imageUrl3: "",
      itemList: [
        {
          explain: "默认是主视频， 在加工视频页放 大显示",
        },
        {
          explain: "",
        },
        {
          explain: "",
        },
      ],
    };
  },
  created() {},
  methods: {
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === "image/jpeg";
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error("上传头像图片只能是 JPG 格式!");
      }
      if (!isLt2M) {
        this.$message.error("上传头像图片大小不能超过 2MB!");
      }
      return isJPG && isLt2M;
    },
  },
};
</script>
<style lang='less' scoped>
.historyOfDevelopment {
  font-size: 0.16rem;
  width: 16.4rem;
  padding-top: 0.4rem;
  padding-left: 0.6rem;
  padding-bottom: 0.6rem;
  .addBtn {
    button{
      width: 0.8rem;
      height: 0.4rem;
      background: rgba(0, 76, 179, 1);
      border-radius: 0.05rem;
      font-weight:bold;
      font-size: 0.18rem;
      color: #fff;  
      outline: none;
      border: none;    
    }

  }
  .itemBox {
    margin-top: 0.15rem;
    width: 15rem;
    font-size: 0.16rem;
    .itemTitle {
      height: 0.6rem;
      line-height: 0.6rem;
      background: rgba(250, 250, 250, 1);
      border: 1px solid rgba(204, 204, 204, 1);
      display: flex;
      div {
        text-align: center;
      }
      .serial_number {
        flex: 5%;
      }
      .title {
        flex: 25%;
      }
      .description {
        flex: 50%;
      }
      .img {
        flex: 20%;
      }
    }
    .itemList {
      display: flex;
      height: 2.4rem;
      border-bottom: 1px solid #cccccc;
      overflow: hidden;
      div {
        text-align: center;
        margin: auto;
      }
      .serial_number {
        flex: 5%;
        line-height: 1.7rem;
      }
      .title {
        flex: 25%;
        input {
          width: 3rem;
          height: 0.4rem;
          border: 0.01rem solid rgba(204, 204, 204, 1);
          outline: none;
        }
      }
      .description {
        flex: 50%;
        .el-textarea {
          width: 6rem;
        }
        /deep/ .el-textarea__inner {
          font-size: 0.16rem;
        }
      }
      .img {
        flex: 20%;
      }
    }
  }
  .btns {
    margin-top: 0.42rem;
    button {
      width: 0.8rem;
      height: 0.4rem;
      border-radius: 0.05rem;
      border: none;
      outline: none;
      color: #fff;
      font-weight: bold;
      font-size: 0.16rem;
    }
    button:nth-child(1) {
      margin-left: 5rem;
      background-color: #e29000;
    }
    button:nth-child(2) {
      background-color: #e20000;
      margin: 0 0.7rem;
    }
    button:nth-child(3) {
      background-color: #004cb3;
    }
  }
  .uploads {
    .avatar-uploader .el-upload {
      border: 1px dashed #d9d9d9;
      border-radius: 6px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
    }
    .avatar-uploader .el-upload:hover {
      border-color: #409eff;
    }
    .avatar-uploader-icon {
      font-size: 28px;
      color: #8c939d;
      width: 2.4rem;
      height: 1.8rem;
      line-height: 1.8rem;
      text-align: center;
      border: 1px solid rgba(204, 204, 204, 1);
    }
    .avatar {
      width: 2.4rem;
      height: 1.8rem;
      // border: 1px solid rgba(204, 204, 204, 1);
      display: block;
    }
  }
}
</style>